package com.example.app.components


import androidx.compose.material.Icon
import androidx.compose.material.IconButton
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.AccountBox
import androidx.compose.material.icons.filled.TrackChanges
import androidx.compose.material.icons.filled.Translate
import androidx.compose.runtime.Composable
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.tooling.preview.Preview
import com.example.app.R

@Composable
fun IconSample() {
    // 使用官方库
    // contentDescription无障碍
    // 部分图标是不能使用的,如果使用必须导入官方图标的扩展库(在build.gradle中配置)
    // tint设置图标颜色
//    Icon(imageVector = Icons.Default.Translate, contentDescription = null, tint = Color.Magenta)
    // 本地图标资源
//    Icon(painter = painterResource(id = R.drawable.ic_android_black_24dp), contentDescription = null, tint = Color.Red)
    IconButton(onClick = { /*TODO*/ }) {
        Icon(painter = painterResource(id = R.drawable.ic_android_black_24dp), contentDescription = null)
    }
}

@Preview(
    showSystemUi = true
)
@Composable
fun IconSamplePreview() {
    IconSample()
}

